package net.cyndeline.scalarlib.rldungeon.grammar

import scalax.collection.GraphEdge.UnDiEdge
import scalax.collection.immutable.Graph
import net.cyndeline.scalarlib.rldungeon.dgs.graph.{DGSFunctionality, Room}
import scalax.collection.GraphPredef.OuterEdge

/**
 * Decides how a set of productions should be applied to construct a graph representing a game map. This includes
 * not only topology, but also game content.
 *
 * @tparam VType Type of vertices used in the graph to be produced.
 * @tparam EType Type of edges used in the graph to be produced.
 */
trait Strategy[VType <: Room[VType], EType[X] <: UnDiEdge[X] with DGSFunctionality[X, EType] with OuterEdge[X, EType]] {

  /**
   * Produces a graph representation of a map.
   *
   * @param initialGraph The graph that the productions initially will be applied to.
   * @return the finished map graph if one was possible to produce according to the strategy, otherwise None.
   *         The resulting graph must have a single start room and a single goal, and be connected.
   */
  def apply(initialGraph: Graph[VType, EType]): Option[Graph[VType, EType]]

}
